#pragma once

template<class T>
class ArrayCalcs
{
public:
	static T max(T a[], int last_index)
	{
		if (last_index <= 0)
		{
			return *a;
		}
		else
		{
			T b = max(a, last_index - 1);
			if (a[last_index] > b)
			{
				return a[last_index];
			}
			else
			{
				return b;
			}
		}
	}

	static T min(T a[], int last_index)
	{
		if (last_index <= 0)
		{
			return *a;
		}
		else
		{
			T b = min(a, last_index - 1);
			if (a[last_index] < b)
			{
				return a[last_index];
			}
			else
			{
				return b;
			}
		}
	}

	static T sum(T a[], int last_index)
	{
		if (last_index <= 0)
		{
			return *a;
		}
		else
		{
			return a[last_index] + sum(a, last_index - 1);
		}
	}

	static T prod(T a[], int last_index)
	{
		if (last_index <= 0)
		{
			return *a;
		}
		else
		{
			return a[last_index] * prod(a, last_index - 1);
		}
	}

	static T med(T a[], int last_index)
	{
		return sum(a, last_index) / last_index;
	}
};

